package cn.wsalix.store.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import cn.anlaser.entity.SimpleEntity;
import cn.wsalix.shop.entity.Product;

/**
 * @author Administrator
 * 单据表
 *进货、出货、移库、盘盈、盘亏
 */
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "Bill")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@EntityListeners({ AuditingEntityListener.class })
@Data
@EqualsAndHashCode(callSuper = false)
public class Bill extends SimpleEntity {
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_BILL_WAREHOUSE"), name = "WAREHOUSE_ID")
	private Warehouse warehouse;
	
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_BILL_PRODUCT"), name = "PRODUCT_ID")
	private Product product;
	
	private int count;// 产品数量
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date crtTime;
	
	private String bought;//进货人
}
